const Base = require('./base.js');
const moment = require('moment');

module.exports = class extends Base {
  async listAction() {
    const configId = this.get('config_id');
    const model = this.model('configRecords');
    const res = await model.getList(configId);
    this.success(res);
  }

  async createAction() {
    const data = this.post();
    const model = this.model('configRecords');
    const res = await model.create({
      ...data,
      record_time: moment(new Date()).format('YYYY-MM-DD HH:mm:ss')
    });
    this.success(res);
  }

  async removeAction() {
    const id = this.get('id');
    const model = this.model('configRecords');
    const res = await model.remove(id);
    this.success(res);
  }
};
